# encoding: UTF-8
# 
# Copyright © 2011 Jesse Sielaff
# 

require 'minitest/autorun'
require 'number'

class TestNumber < MiniTest::Unit::TestCase
  def test_new_raises_error
    assert_raises(NoMethodError) { Number.new }
  end
  
  def test_Number_returns_new_number
    assert_equal(1, Number(1).to_i)
  end
  
  def test_Number_with_two_arguments_returns_new_complex_number
    assert_equal(Complex(2,2), Number(2,2).to_c)
  end
  
  def test_Number_with_two_arguments_returns_new_interval_number
    
  end
  
  def test_digits
  end
  
  def test_nan_returns_new_nan_number
    assert_equal(Float::NAN, Number.nan)
  end
  
  def test_pos_inf_returns_new_pos_inf_number
    assert_equal(Float::INFINITY, Number.pos_inf)
  end
  
  def test_neg_inf_returns_new_neg_inf_number
    assert_equal(-Float::INFINITY, Number.neg_inf)
  end
  
  def test_zero_returns_new_zero_number
    assert_equal(0, Number.zero)
  end
  
  def test_one_returns_new_one_number
    assert_equal(1, Number.one)
  end
  
  def test_pi_returns_new_pi_number
    # Need to figure out what kind of assertion to use (in_delta?)
    # assert_equal(Math::PI, Number.pi)
  end
  
  def test_e_returns_new_e_number
    # See above
    # assert_equal(Math::E, Number.e)
  end
  
  def test_i_returns_new_i_number
    assert_equal(1.i, Number.i)
  end
  
  def test_unary_plus_returns_same_number
    assert_equal(1, Number(1).+@)
  end
  
  def test_unary_minus_returns_negative_of_number
    assert_equal(-1, Number(1).-@)
  end
  
  def test_add_returns_sum_of_numbers
    assert_equal(2, Number(1) + Number(1))
  end
  
  def test_subtract_returns_difference_of_numbers
    assert_equal(0, Number(1) - Number(1))
  end
  
  def test_multiply_returns_product_of_numbers
    assert_equal(4, Number(2) * Number(2))
  end
  
  def test_divide_returns_quotient_of_numbers
    assert_equal(1, Number(2) / Number(2))
  end
end
